<!-- subpkg_consult/department/index.vue -->
<script setup>
import { computed, ref } from 'vue';
import { departmentListAPI } from '@/apis/home.js';
     // 获取医生科室列表
    const  departmentLis=ref([])
	function getdepartmentLis(){
		  departmentListAPI().then((res)=>{
			    // console.log(res.data);
				departmentLis.value=res.data
		  }).catch((e)=>{
			  console.log(e);
		  })
	}
	const activeID=ref(0)
	// 点击高亮逻辑
	function IndexActive(index){
		activeID.value=index
	}
	
	// 获取医生科室列表二级
     let departmenChild=computed(()=>departmentLis.value[activeID.value].child)
	 
	 
	 
	 const prop=defineProps(['type','illnessType'])
	
	// 获取医生科室列表 
	getdepartmentLis()
</script>

<template>
  <view class="department-page" v-if="departmentLis.length>0">
    <scroll-view scroll-y class="department-primary">
      <view class="department-item " v-for="(item,index) in departmentLis"
		:key="item.id" :class="{active:activeID==index }" @click="IndexActive(index)"> {{item.name}}</view>
     
    </scroll-view>
    <scroll-view class="department-secondary" >
      <navigator
        hover-class="none"
        :url="`/subpack_consult/description/index?type=${prop.type}&illnessType=${prop.illnessType}&depId=${item.id }`"
        class="department-item"
		v-for="(item,index) in departmenChild"
		:key="item.id "
      >
	  <!-- <image :src="item.avatar" style="width: 50px; height: 50px;"></image> -->
      {{item.name}}
      </navigator>
    </scroll-view>
  </view>
</template>

<style lang="scss">
  @import './index.scss';
</style>
